package com.java.project_1;

import java.util.Scanner;

public class Unitlity {
    private static Scanner sc = new Scanner(System.in);

    public static char readMeanSelecation() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1);
            c = str.charAt(0);
            if (c != '1' && c != '2' && c != '3' && c != '4') {
                System.out.print("你输入的值有误，请重新输入");
            } else break;
        }
        return c;
    }

    public static int readNumber() {
        int n;
        for (; ; ) {
            String str = readKeyBoard(4);
            try {
                n = Integer.parseInt(str);
                break;
            } catch (NumberFormatException e) {
                System.out.println("数字错误，请重新输入：");

            }
        }
        return n;
    }

    private static String readKeyBoard(int i) {
        // TODO Auto-generated method stub
        return null;
    }

    public static String readString() {
        String str = readKeyBoard(8);
        return str;
    }

    public static char readConFirmSelection() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1).toUpperCase();
            c = str.charAt(0);
            if (c == 'Y' || c == 'N') {
                break;
            } else {
                System.out.println("选择错误，请重新输入");
            }


        }
        return c;
    }
}

		
